A video encoder can maintain a VBV Buffer (Video Buffering Verifier Buffer) that emulates a decoding device's input buffer. The video encoder can generate a bitstream, and use the model of the VBV Buffer to adjust the bitrate of the bitstream such that it avoids overflow and/or underflow of the VBV Buffer.
The fullness level of the VBV Buffer can be modeled over time by comparing a constant input rate tied to an average number of bits per frame with a variable output rate tied to the actual bitrate of the generated bitstream. When the modeled fullness level nears a maximum threshold, the encoder can decrease values of a quantization parameter to increase the bitstream's bitrate. Such an increase in the bitstream's bitrate can raise the output rate closer to the constant input rate, and thereby decrease the modeled fullness level. Similarly, when the modeled fullness level nears a minimum threshold, the encoder can increase values of the quantization parameter to decrease the bitstream's bitrate. Such a decrease in the bitstream's bitrate can lower the output rate closer to the constant input rate, and thereby increase the modeled fullness level.
When an encoder is encoding multiple frames in parallel with one another, the actual fullness level of the VBV may not be available, as frames earlier in the coding order might not yet be finished encoding. As such, the encoder can estimate what the fullness level would be immediately prior to each parallel frame. This can allow the encoder to find a value for the quantization parameter to use when beginning encoding of each parallel frame.
However, estimations of the fullness level just prior to each parallel frame can be inaccurate, as they can rely on an estimate of how many bits will be generated per frame. If the actual number of bits differs from the estimates, the selected value of the quantization parameter can be too low, resulting in too many bits being generated for the bitstream. A bitstream with too many bits runs the risk of underflowing the VBV Buffer.